<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <script type="text/javascript" src="../../script/api.js"></script>
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #f7911b;height: 3rem;">
        <a class="aui-pull-left"><span class="aui-iconfont aui-icon-left" onclick="api.closeWin()"></span></a>
        <div class="aui-title">设置提领密码</div>
    </header>

    <div class="aui-content aui-margin-t-15">
        <span>设置6位数字提领密码</span>
        <label><input id="TiLingPas" type="text" maxlength="6" ></label>
    </div>

    <p>
        <div class="aui-btn aui-btn-block aui-margin-t-15" onclick="right()">确定</div>
    </p>
</body>
<script type="text/javascript">
    apiready = function() {
        window.right = function() {
            var TiLingPas = $api.byId('TiLingPas');
            TiLingPasValue = TiLingPas.value;
            var token = '';
            var body = {
                token: $api.getStorage('token'),
                TiLingPas: TiLingPasValue
            };
            var reg = new RegExp(/^(\d){6}$/g);
            if (reg.test(TiLingPasValue)) {
                api.ajax({
                    url: 'http://www.mk517.com/webApi/SetTilingPas.php',
                    method: 'post',
                    "headers": {
                        "Content-Type": "application/json"
                    },
                    dataType: "json",
                    data: {
                        body: body
                    }
                }, function(ret, err) {
                    if (ret) {
                        api.alert({
                            msg: '设置成功',
                          
                        }, function(ret, err) {
                            if (ret) {
                                // alert( JSON.stringify( ret ) );
                            } else {
                                // alert(JSON.stringify(err));
                            }
                        });

                    } else {
                        // alert(JSON.stringify(err));
                    }
                });
            } else {
                api.alert({
                    msg: '提领密码不能为空且必须为6位'
                }, function(ret, err) {

                });

            }
        }


    }
</script>

</html>
